-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to use rebar3 fmt instead of standalone erlfmt #4811
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good! See my comment here.
autoload/ale/erlang.vim
Outdated
call ale#Set('erlang_rebar_executable', 'rebar3') | ||
call ale#Set('erlang_rebar_use_global', get(g:, 'ale_use_global_executables', 0)) | ||
|
||
function! ale#erlang#GetRebarExecutable(buffer) abort |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a runtime cost in loading this file, and we only have this one function and call it from one place. Let's just move this into the fixer file instead, to avoid this runtime cost.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@w0rp Thank you for your feedback! I have addressed the points you raised. Could you please review the changes again? |
let l:executable = ale#fixers#erlfmt#GetExecutable(a:buffer) | ||
let l:use_rebar = ale#Var(a:buffer, 'erlang_erlfmt_use_rebar') | ||
|
||
if l:use_rebar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be clearer if the two cases were handled in separate functions, like this:
function! ale#fixers#erlfmt#Fix(buffer) abort
return ale#Var(a:buffer, 'erlang_erlfmt_use_rebar3')
\ ? s:FixWithRebar3(a:buffer)
\ : s:FixWithEscript(a:buffer)
endfunction
However, it seems to me that from user's perspective it would be better to add separate rebar3_fmt
fixer.
The current implementation of the fixer for erlfmt, an Erlang code formatter, invokes a standalone
erlfmt
command. However, the standaloneerlfmt
command is not distributed by default. Instead, erlfmt is often used as a plugin for Rebar3, the de facto build tool for Erlang.This patch introduces a new option
g:ale_erlang_erlfmt_use_rebar
, which is disabled by default, allowing the use ofrebar3 fmt
instead.Additionally, this patch fixes a bug that caused the command to read the original source code rather than the stdin.